package homeWork;

import java.util.Scanner;

public class homeWork {
    public static void main(String[] args) {
        System.out.println("请输入一个整数");
        Scanner scanner = new Scanner(System.in);
        int num = scanner.nextInt();
        int count = countOnce(num);
        System.out.println(num +"的二进制表示中1的个数为："+count);
    }
    public static int countOnce(int num){
        int count = 0;
        while(num!=0){
            count += num & 1;
            num >>>= 1;
        }
        return count;
    }
}
